<?php
include('admin.php');
set_page_info('id', 'front page');
set_page_info('title', 'Frontpage Setting');

get_header();
?>

<h2>Frontpage Setup</h2>

<script>
	$(function() {
		$( "#tabs" ).tabs();
	});
</script>


<div id="tabs">
	<ul>
		<li><a href="#start">Start</a></li>
		<li><a href="#boks1">Boks 1</a></li>
        <li><a href="#boks2">Boks 2</a></li>
        <li><a href="#boks3">Boks 3</a></li>
        <li><a href="#boks4">Boks 4</a></li>
    </ul>
    
       <div id="start">
       <?php
		$mysql = new mysql($dbinfo);
		$mysql->connect(); 
		
		
		if (isset($_POST['submit']) == "Save" && isset($_POST['boks1']) == 1)
		{
				$mysql_query_str = "UPDATE aa_boks SET title = '$_POST[boks_title]', text = '$_POST[boks_content]', linkname = '$_POST[boks_linkname]', url = '$_POST[boks_url]', target = '$_POST[boks_target]' WHERE  id =1";
				mysql_query($mysql_query_str) or die(mysql_error());
				print "<p class=\"success\">The settings have been saved.</p>";
		} 
		
		if (isset($_POST['submit']) == "Save" && isset($_POST['boks2']) == 2)
		{
				$mysql_query_str = "UPDATE aa_boks SET title = '$_POST[boks_title]', text = '$_POST[boks_content]', linkname = '$_POST[boks_linkname]', url = '$_POST[boks_url]', target = '$_POST[boks_target]' WHERE  id =2";
				mysql_query($mysql_query_str) or die(mysql_error());
				print "<p class=\"success\">The settings have been saved.</p>";
		} 
		
		if (isset($_POST['submit']) == "Save" && isset($_POST['boks3']) == 3)
		{
				$mysql_query_str = "UPDATE aa_boks SET title = '$_POST[boks_title]', text = '$_POST[boks_content]', linkname = '$_POST[boks_linkname]', url = '$_POST[boks_url]', target = '$_POST[boks_target]' WHERE  id =3";
				mysql_query($mysql_query_str) or die(mysql_error());
				print "<p class=\"success\">The settings have been saved.</p>";
		} 
		if (isset($_POST['submit']) == "Save" && isset($_POST['boks4']) == 4)
		{
				$mysql_query_str = "UPDATE aa_boks SET title = '$_POST[boks_title]', text = '$_POST[boks_content]', linkname = '$_POST[boks_linkname]', url = '$_POST[boks_url]', target = '$_POST[boks_target]' WHERE  id = 4";
				mysql_query($mysql_query_str) or die(mysql_error());
				print "<p class=\"success\">The settings have been saved.</p>";
		} 
		
		
		?>

       <p>Please choose one of the box you want to edit</p>
       </div>
       <?php 
	  
	   
	   $sql_select_query = "select * from aa_boks LIMIT 0, 5";
	   $mysql_result = mysql_query($sql_select_query);
	   while($datarow = mysql_fetch_array($mysql_result))
	   {
	   
	   
        print "<div id=\"boks".$datarow['id']."\">";
        print "<form action=\"frontpage_setting.php\" method=\"post\">";
        print "<p><label for=\"boks_title\">Title</label>";
		print "<input type=\"hidden\" id=\"boks".$datarow['id']."\" name=\"boks".$datarow['id']."\" value=\"".$datarow['id']."\" />"; 
        print "<input type=\"text\" name=\"boks_title\" id=\"boks_title\" value=\"".$datarow['title']."\" /> </p>";
		print "<p><label for=\"boks_content\">Content</label>";  
        print "<textarea type=\"text\" name=\"boks_content\" id=\"boks_title\">".$datarow['text']."</textarea></p>";
        print "<p><label for=\"boks_linkname\">Link name</label>"; 
        print "<input type=\"text\" name=\"boks_linkname\" id=\"boks_linkname\" value=\"".$datarow['linkname']."\" /> </p>";
		print "<p><label for=\"boks_url\">URL</label>"; 
        print "<input type=\"text\" name=\"boks_url\" id=\"boks_url\" value=\"".$datarow['url']."\" /></p>";
        print "<p><label for=\"boks_target\">Target</label>"; 
        print "<input type=\"text\" name=\"boks_target\" id=\"boks_target\" value=\"".$datarow['target']."\" /></p>";
        print "<p><input type=\"submit\" name=\"submit\" class=\"button\" value=\"Save\" />";
        print "</p></form></div>";
		 
	    }
		?>
       
		
	
</div>







<?php get_footer(); ?>



